package common;

import bean.Car;
import com.spring.beans.BeansException;
import com.spring.beans.factory.config.BeanPostProcessor;

/**
 * @Description: This is a sample class.
 * @Author: Simon
 */
public class CustomBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("customBeanPostProcessor#processorBeforeInitialization");
        if ("car".equals(beanName)){
            ((Car)bean).setBrand("rolls-royce");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("customBeanPostProcessor#processorAfterInitialization");

        return bean;
    }
}
